<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"   import="pojo.*,java.util.*"
    %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
<style type="text/css">
   table{
      border:1px solid blue;
      margin:0 auto;
      width:600px;
     border-collapse: collapse;
   }
   .nav{
   width:300px;
   margin:0 auto;
   }
   .buy{
     margin:0 auto;
      width:600px;
      text-align:center;
   }
</style>
<script type="text/javascript">
   function add(){
	    var num = document.getElementById("count").value;
	    document.getElementById("count").value=(parseInt(num)+1)+"";
	    return false;
   }
   function reduce(){
	    var num = document.getElementById("count").value;
	    document.getElementById("count").value=num-1;
	    return false;
  }
</script>
</head>
<body>
<% 
   PageBean<Cart> pb = (PageBean<Cart>)(request.getAttribute("pb"));
 %>
 <a href="show.jsp">继续购物</a>
 <form action="OrderServlet?method=confirm" method="post">
<table border=1>
  <tr>
  <th><input type="checkbox" value="全选"/>全选</th>
   <th>商品名称</th>
   <th>商品图片</th>
    <th>商品数量</th>
    <th>商品单价</th>
    <th>总金额</th>
    <th>操作</th>
 </tr>
 <%
    for(Cart p:pb.getList()){
  %>
   <tr>
   <td><input type="checkbox" value="<%=p.getP_id()%>" name="pid"/></td>
   <td> <%=p.getP_name() %></td>
   <td>  <img src="<%=p.getP_image() %>" width="50px" height="50px"/></td>
      <td><button onclick="return reduce();">-</button>
      <input type="text" name="pquantity" size="5" id="count" value="<%=p.getQuantity()%>"/>
      <button onclick="return add();">+</button></td>
      <td>    <%=p.getP_price()%></td>
      <td>      <%=p.getAmount()%></td>
      <td><a href="<%=request.getContextPath()%>/CartServlet?method=del">删除</a></td>
 </tr>
 <%} %>
</table>
<div class="buy"><button>结算</button></div>
</form>
  <div class="nav">
<%
   for(int i=1;i<=pb.getTotalPage();i++){
	   %>
	 
	   [
<a href="<%=request.getContextPath() %>/CartServleta?method=showCart&pageSize=5&currentPage=<%=i%>">
	   <%=i %></a>]
	  
<%} %>
 </div>
</body>
</html>